<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>爬虫源列表</title>
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css">
    <link rel="stylesheet" href="{{ url_for('static', filename='styles.css') }}">
</head>
<body>
   {% include 'navbar.html' %}

    <div class="container mt-5">
        <h1 class="mb-4 text-center">爬虫源列表</h1>

        <a href="/source/create" class="btn btn-primary mb-3">创建新爬虫源</a>
        <div class="table-responsive">
            <table class="table table-striped">
                <thead>
                    <tr>
                        <th>ID</th>
                        <th>源站名称</th>
                        <th>爬取规则</th>
                        <th>状态</th>
                        <th>操作</th>
                    </tr>
                </thead>
                <tbody>
                    {% for source in sources %}
                    <tr>
                        <td>{{ source.id }}</td>
                        <td>{{ source.source_name }}</td>
                        <td>{{ source.crawl_rule }}</td>
                        <td>
                            {% if source.source_status == 1 %}开启
                            {% else %}关闭
                            {% endif %}
                        </td>
                        <td>
                            <a href="{{ url_for('edit_source', source_id=source.id) }}" class="btn btn-warning btn-sm">编辑</a>
                            <form action="{{ url_for('delete_source', source_id=source.id) }}" method="post" style="display:inline;">
                                <button type="submit" class="btn btn-danger btn-sm" onclick="return confirm('确认删除爬虫源吗？')">删除</button>
                            </form>
                        </td>
                    </tr>
                    {% endfor %}
                </tbody>
            </table>
        </div>
    </div>

    <script src="https://code.jquery.com/jquery-3.5.1.slim.min.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/@popperjs/core@2.11.6/dist/umd/popper.min.js"></script>
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js"></script>
</body>
</html>
